{% extends 'blog/base.html' %}
{% load blog_tags %}
{% block title %}博客首页{% endblock %}
{% block script %}
<script>
    $(".django-ckeditor-widget").removeAttr('style');
</script>
{% endblock script %}
{% block content %}
<div class="content-body">
    <div class="container">
        <div class="row">
            <main class="col-md-8">
                <article class="post post-1">
                    <header class="entry-header">
                        <h1 class="entry-title">{{post.title}}</h1>
                        <div class="entry-meta">
                            <span class="post-category"><a href="#">{{ post.title }}</a></span>
                            <span class="post-date"><a href="#"><time class="entry-date"
                                                                      datetime="2012-11-09T23:15:57+00:00">{{ post.publish }}</time></a></span>
                            <span class="post-author"><a href="#">{{ post.author }}</a></span>
                            <span class="comments-link"><a href="#">4 评论</a></span>
                            <span class="views-count"><a href="#">{{ post.views }} 阅读</a></span>
                        </div>
                    </header>
                    <div class="entry-content clearfix">
                        {{ post.body|safe}}
                    </div>
                </article>
                <section class="comment-area" id="comment-area">
                    <hr>
                    <h3>发表评论</h3>
                    <form action="{{ path }}" method="post" class="comment-form">
                        {% csrf_token %}
                        <div class="row">
                            <div class="col-md-4">
                                <label for="id_name">名字：</label>
                                <input type="text" id="id_name" name="name" required>
                            </div>
                            <div class="col-md-4">
                                <label for="id_email">邮箱：</label>
                                <input type="email" id="id_email" name="email" required>
                            </div>
                            <div class="col-md-12">
                                <label for="id_comment">评论：</label>
                                <div>
                                    {{ comment_form.media }}
                                    {{ comment_form.body }}
                                </div>
                                 <button type="submit" class="comment-btn">发表</button>
                            </div>
                        </div>
                    </form>
                    <div class="comment-list-panel">
                        <h3>评论列表，共 <span>{{ comments.count }}</span> 条评论</h3>
                        <ul class="comment-list list-unstyled">
                            {% for comment in comments %}
                                 <li class="comment-item">
                                <span class="nickname">{{ comment.name }}</span>
                                <time class="submit-date" datetime="2012-11-09T23:15:57+00:00">{{ comment.created }}</time>
                                <div class="text">
                                    {{ comment.body|safe }}
                                </div>
                            </li>
                            {% endfor %}
                        </ul>
                    </div>
                </section>
            </main>
            <aside class="col-md-4">
                {% if post.toc %}
                    <div class="widget widget-content">
                        <h3 class="widget-title">文章目录</h3>
                            <div class="toc">
                                {{ post.toc|safe }}
                            </div>
                    </div>
                {% endif %}
                <div class="widget widget-recent-posts">
                    <h3 class="widget-title">最新文章</h3>
                    <ul>
                        {% show_latest_posts 3 %}
                    </ul>
                </div>
                <div class="widget widget-archives">
                    <h3 class="widget-title">归档</h3>
                    <ul>
                        {% pigeonhole_list_posts %}
                    </ul>
                </div>

                <div class="widget widget-category">
                    <h3 class="widget-title">分类</h3>
                    <ul>
                        {% for category in categorys %}
                        <li>
                            <a href="{% url 'blog:post_category' category.class_name %} ">{{ category.class_name }} <span class="post-count">({{ category.posts_category.count }})</span></a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>

                <div class="widget widget-tag-cloud">
                    <h3 class="widget-title">标签云</h3>
                    <ul>
                        {% for tags in post.tags.all %}
                            <li>
                            <a href="{% url 'blog:post_tags' tags.name %}">{{ tags.name }}</a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
                <div class="rss">
                    <a href="{% url 'blog:post_feed' %}"><span class="ion-social-rss-outline"></span> RSS 订阅</a>
                </div>
            </aside>
        </div>
    </div>
</div>
{% endblock %}